<!--
/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * Copyright 2014 The moOde audio player project / Tim Curtis
 * Copyright 2020 @bitlab (@bitkeeper Git)
*/
-->
<div id="container">
<div class="container">
	<h1 class="cdsp-config">CamillaDSP</h1>
	<p class="sub-legend>">Version: $_select[version]</p>
	<p>
    CamillaDSP 是一个数字信号处理 (DSP) 工具，用于音频的路由和过滤。
    它可以用于软件分频器、房间校正、均衡和许多其他类型的 DSP。
    查看 <a class="target-blank-link" href="https://github.com/HEnquist/camilladsp?tab=readme-ov-file#table-of-contents" target="_blank">CamillaDSP 文档</a> 以获取更多信息。<br>
</p>

<form class="form-horizontal" action="" method="post">
    <legend>配置
        <button class="legend-config btn btn-medium btn-primary btn-submit" type="submit" name="save" value="1" $_save_disabled>更新</button>
    </legend>
    <p class="sub-legend $_camilladsp_set_disabled_message">
        要使用 CamillaDSP，请在音频和多房间配置中关闭所有其他 DSP、均衡和多房间选项。
    </p>

    <div class="config-horiz-rule">常规</div>

    <div class="control-group">
        <label class="control-label" for="cdsp-mode">信号处理</label>
        <div class="controls">
            <select id="cdsp-mode" class="config-select-xxlarge" name="cdsp_mode" $_save_disabled>
                $_select[cdsp_mode]
            </select>
            <a aria-label="帮助" class="config-info-toggle" data-cmd="info-cdsp-mode" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
            <span id="cdsp-config-description" class="config-help-static">
                $_config_description
            </span>
            <span id="info-cdsp-mode" class="config-help-info">
                <b>关闭:</b> 不进行信号处理。<br>
                <b>自定义:</b> 手动创建 CamillaDSP 设置，例如在使用多个输出设备时。<br>
                <b>快速卷积:</b> 使用下面的“快速卷积滤波器”选择来提供基本的卷积和增益。<br>
                <b>配置:</b> 使用列出的管道配置之一。
            </span>
        </div>

        <label class="control-label">默认设备选项</label>
        <div class="controls">
            <div class="toggle">
                <label class="toggle-radio toggle-cdsp-use-default-device" for="toggle-cdsp-use-default-device-2">开启 </label>$_select[cdsp_use_default_device_on]
                <label class="toggle-radio toggle-cdsp-use-default-device" for="toggle-cdsp-use-default-device-1">关闭</label>$_select[cdsp_use_default_device_off]
            </div>
            <a aria-label="帮助" class="config-info-toggle" data-cmd="info-cdsp-use-default-device" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
            <span class="config-help-static">
                ALSA: $_alsa_output_mode
            </span>
            <span id="info-cdsp-use-default-device" class="config-help-info">
                <b>开启:</b> 使用音频配置中定义的输出设备和模式，以及与音频设备报告的最高位深度相等的播放位深度。<br>
                <b>关闭:</b> 使用管道编辑器指定设备选项，例如如果您想创建多通道分频器或设置特定的播放位深度。
            </span>
        </div>
    </div>
</form>


          <label class="control-label" for="log-level">日志级别</label>
<div class="controls">
    <select id="log-level" name="log_level" class="config-select-large">
        $_cdsp_log_level
    </select>
    <a aria-label="帮助" class="config-info-toggle" data-cmd="info-log-level" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
    <span id="info-log-level" class="config-help-info">
        控制 CamillaDSP 条目在 MPD 日志中的详细程度。
    </span>
</div>
</div>

<div class="config-horiz-rule">快速卷积滤波器</div>

<div class="control-group">
    <label class="control-label" for="cdsp-qc-gain">增益 (dB)</label>
    <div class="controls">
        <input class="config-input-large" type="number" maxlength="3" min="-40" max="20" step="0.1" id="cdsp-qc-gain" name="cdsp_qc_gain" value="$_cdsp_qc_gain">
        <a aria-label="帮助" class="config-info-toggle" data-cmd="info-cdsp-qc-gain" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
        <span id="info-cdsp-qc-gain" class="config-help-info">
            调整增益可以帮助防止剪辑。范围是 -40dB 到 20dB。打开管道编辑器以查看信号是否剪辑或显示滤波器的频率曲线。
        </span>
    </div>

    <label class="control-label" for="cdsp-qc-ir-left">左侧冲激响应</label>
    <div class="controls">
        <select id="cdsp-qc-ir-left" class="config-select-xxlarge" name="cdsp_qc_ir_left">
            $_select[cdsp_qc_ir_left]
        </select>
        <a aria-label="帮助" class="config-info-toggle" data-cmd="info-cdsp-qc-ir-left" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
        <span id="info-cdsp-qc-ir-left" class="config-help-info">
            选择用于卷积的冲激响应。新的冲激响应文件可以在文件管理部分添加。
        </span>
    </div>

    <label class="control-label" for="cdsp-qc-ir-right">右侧冲激响应</label>
    <div class="controls">
        <select id="cdsp-qc-ir-right" class="config-select-xxlarge" name="cdsp_qc_ir_right">
            $_select[cdsp_qc_ir_right]
        </select>
        <a aria-label="帮助" class="config-info-toggle" data-cmd="info-cdsp-qc-right" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
        <span id="info-cdsp-qc-right" class="config-help-info">
            选择用于卷积的冲激响应。新的冲激响应文件可以在文件管理部分添加。
        </span>
    </div>

    <label class="control-label" for="cdsp-qc-ir-type">类型/格式</label>
    <div class="controls">
        <select id="cdsp-qc-ir-type" class="config-select-large" name="cdsp_qc_ir_type">
            $_select[cdsp_qc_ir_type]
        </select>
        <a aria-label="帮助" class="config-info-toggle" data-cmd="info-cdsp-qc-type" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
        $_check_msg_quick_convolution
        <span id="info-cdsp-qc-type" class="config-help-info">
            指定所选冲激响应文件的类型。注意对 wav 文件选择 WAVE，文件无需转换为原始格式。
        </span>
    </div>
</div>


	<form class="form-horizontal" action="#pipeline-editor" method="post">
		<a id="pipeline-editor"></a>

	<legend>管道编辑器
    <a href="cdsp-configeditor.php" target="camillagui">
        <button class="legend-config btn btn-medium btn-primary" $_open_camillagui_disabled>打开</button>
    </a>
</legend>

<div class="control-group">
    <span class="config-help-static $_camillagui_notfound_show">
        <span style='color: red'>&#10007;</span> 找不到或未安装管道编辑器。
    </span>
    <span class="config-help-static $_camillagui_status_problems">
        <span style='color: red'>&#10007;</span> 管道编辑器出现未知问题。
    </span>

    <label class="control-label">状态</label>
    <div class="controls">
        <div class="toggle">
            <label class="toggle-radio toggle-camillagui" for="toggle-camillagui-2">开启 </label>$_select[camillagui_on]
            <label class="toggle-radio toggle-camillagui" for="toggle-camillagui-1">关闭</label>$_select[camillagui_off]
        </div>
        <a aria-label="帮助" class="config-info-toggle" data-cmd="info-camillagui" href="#notarget">
            <i class="fa-regular fa-sharp fa-info-circle"></i>
        </a>
        <span id="info-camillagui" class="config-help-info">
            显示管道编辑器网络服务的当前开启/关闭状态。
        </span>
        <button id="btn-update-camilla-gui" class="btn btn-medium btn-primary btn-submit" type="submit" name="update_camillagui" value="1" style="display:none"/>
    </div>

    <label class="control-label">专家模式</label>
    <div class="controls">
        <div class="toggle">
            <label class="toggle-radio toggle-camillaguiexpert" for="toggle-camillaguiexpert-2">开启 </label>$_select[camillaguiexpert_on]
            <label class="toggle-radio toggle-camillaguiexpert" for="toggle-camillaguiexpert-1">关闭</label>$_select[camillaguiexpert_off]
        </div>
        <a aria-label="帮助" class="config-info-toggle" data-cmd="info-camillaguiexpert" href="#notarget">
            <i class="fa-regular fa-sharp fa-info-circle"></i>
        </a>
        <span id="info-camillaguiexpert" class="config-help-info">
            显示高级选项，例如播放/捕获设备设置和重采样。
        </span>
        <button id="btn-update-camilla-gui-expert" class="btn btn-medium btn-primary btn-submit" type="submit" name="update_camillagui_expert" value="1" style="display:none"/>
    </div>
</div>


<legend>文件管理</legend>
<form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
<div class="control-group">
<label class="control-label" for="cdsp-config">配置</label>
<div class="controls">
<select id="cdsp-config" class="config-select-xxlarge" name="cdsp_config" onchange="$('#btn-automatic-check').click();">
$_select[cdsp_config]
</select>
<a aria-label="帮助" class="config-info-toggle" data-cmd="info-cdsp-config" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
<span class="config-help-static">$_check_msg_config</span>
<span id="info-cdsp-config" class="config-help-info">
查看 <a class="target-blank-link" href="https://github.com/HEnquist/camilladsp?tab=readme-ov-file#table-of-contents" target="_blank">CamillaDSP 文档</a> 以获取有关管道配置文件的信息。<br>
<b>V2 示例配置</b><br>
<table class="cdsp-help-table">
<tr><td>ASH-IR R02 控制室</td><td>来自 ASH-IR 数据集的双耳房间脉冲响应 R02 控制室（不带 HpCF）</td></tr>
<tr><td>交叉反馈 Bs2b</td><td>来自 Wang-Yue 的 Bs2b，包含 5 套设置。有关更多信息，请参阅链接</td></tr>
<tr><td>交叉反馈 Mikhail</td><td>Mikhail Naganov，可根据自己的 IR 校正进行自定义</td></tr>
<tr><td>交叉反馈 MPM</td><td>Mikhail Phonitor Mini (MPM)。Mikhail Naganov 反向工程的 SPL Phonitor Mini 交叉反馈，具有 Ebert-Hanke 开发的 DSP</td></tr>
<tr><td>交叉反馈 Natural</td><td>Ebert-Hanke 实现的 Natural，大致基于 Jan Meier 的一些出版物建模</td></tr>
<tr><td>交叉反馈 Chu Moy</td><td>Ebert-Hanke 实现的 Pow Chu Moy 交叉反馈，基于 Linkwitz</td></tr>
<tr><td>平坦</td><td>无信号处理</td></tr>
<tr><td>响度</td><td>响度音量曲线，具有 3dB 高增益、6dB 低增益和 -3dB 降幅</td></tr>
<tr><td>MS 矩阵窄</td><td>M-S（中侧）矩阵，侧信号减弱</td></tr>
<tr><td>MS 矩阵宽</td><td>M-S（中侧）矩阵，侧信号增强</td></tr>
<tr><td>10 波段参数均衡器</td><td>通用的 10 波段参数均衡器示例</td></tr>
<tr><td>极性反转</td><td>在两个通道上反转 +/- 极性</td></tr>
<tr><td>ProtoDAC</td><td>ProtoDAC TDA1387 X8 非过采样 DAC。在两个通道上反转 +/- 信号极性，并对 16 位样本应用平坦抖动</td></tr>
<tr><td>Trifield 3 通道</td><td>基于 Michael Gerzon 的 Trifield 解码器。需要至少 3 个可用于输出的通道</td></tr>
</table>
</span>
<button id="btn-automatic-check" class="btn btn-medium btn-primary btn-submit" type="submit" name="check_auto" value="1" style="display:none"></button>
</div>
</div>
</form>

		<div class="controls">
    <a data-toggle="modal" href="#remove-pipeline"><button class="btn btn-medium btn-primary config-btn">删除</button></a>
    <a data-toggle="modal" href="#copy-pipeline"><button class="btn btn-medium btn-primary config-btn">复制</button></a>
    <a data-toggle="modal" href="#create-new-pipeline"><button class="btn btn-medium btn-primary config-btn">新建</button></a>
    <button class="btn btn-medium btn-primary config-btn" type="submit" name="export" value="1">下载</button>

    <label for="pipeline-config" id="choose-pipeline-cfg" class="btn btn-primary btn-medium config-btn">上传</label>
    <input type="file" id="pipeline-config" accept=".yml" name="pipeline_config" style="display:none" onchange="$('#btn-import-pipeline').click();" >
    <button id="btn-import-pipeline" class="btn btn-medium btn-primary btn-submit" type="submit" name="import" value="1" style="display:none"/>

    <button class="btn btn-medium btn-primary btn-submit config-btn" type="submit" name="check" value="1">检查</button>
    <a aria-label="帮助" class="config-info-toggle" data-cmd="info-configuration-actions" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
    <span id="info-configuration-actions" class="config-help-info">
        <b>删除：</b> 删除所选的配置文件。<br>
        <b>复制：</b> 将所选的配置文件复制为一个不同名称的新文件。<br>
        <b>新建：</b> 创建一个具有最少所需设置的新配置。<br>
        <b>下载：</b> 下载所选的配置文件。<br>
        <b>上传：</b> 上传配置文件。如果文件已存在，将被覆盖。<br>
        <b>检查：</b> 检查所选配置是否有效。
        <br><br>
        <b>使用说明：</b><br>
        对配置的更改在暂停/停止播放后立即生效。如果 CamillaDSP 无法播放音频，将在 MPD 日志中报告错误 <code>/var/log/mpd/log</code>。如果这是由于音频设备不支持的通道数或采样率造成的，请调整 CamillaDSP 混音器或重采样器，或更改传递给 CamillaDSP 的音频格式，位于 ALSA 配置文件 <code>/etc/alsa/conf.d/camilladsp.conf</code> 中。此文件中的错误通常在 <code>/var/log/moode.log</code> 和 <code>/var/log/syslog</code> 中报告。
    </span>
</div>


	<form class="form-horizontal" action="#conv-file" method="post" enctype="multipart/form-data">
	<a id="conv-file"></a>

	<div class="control-group">
		<label class="control-label" for="cdsp-coeffs">卷积</label>
		<div class="controls">
			<select id="cdsp-coeffs" class="config-select-xxlarge" name="cdsp_coeffs" onchange="$('#coeff_remove_id').val($('#cdsp-coeffs :selected').val() );$('#btn-check-coeff').click();">
				$_select[cdsp_coeffs]
			</select>
			<a aria-label="帮助" class="config-info-toggle" data-cmd="info-cdsp-coeffs" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
			<div id="info-cdsp-coeffs" class="config-help-info">
				查看 <a class="target-blank-link" href="https://github.com/HEnquist/camilladsp#fir" target="_blank">CamillaDSP 文档</a>，了解脉冲响应文件的信息。<br>
			</div>
			<span class="config-help-static">
				<table class="cdsp-help-table">
					$_coeff_info_html
				</table>
			</span>
		</div>

		<!-- IDs 和名称不正确: (上面的复制) -->
		<div class="controls">
			<a data-toggle="modal" href="#remove-coeff"><button class="btn btn-medium btn-primary config-btn">移除</button></a>
			<button class="btn btn-medium btn-primary config-btn" type="submit" name="export" value="1">下载</button>
			<label for="coeffs-file" id="choose-coeff-cfg" class="btn btn-medium btn-primary config-btn">上传</label>
			<input type="file" id="coeffs-file" accept=".wav,.txt,.raw,.csv" name="coeffs_file" style="display:none" onchange="$('#btn-import-coeff').click();">
			<button id="btn-import-coeff" class="btn btn-medium btn-primary config-btn btn-submit" type="submit" name="import" value="1" style="display:none"></button>
			<button id="btn-check-coeff" class="btn btn-medium btn-primary config-btn btn-submit" type="submit" name="info" value="1" style="display:none">信息</button>
			<a aria-label="帮助" class="config-info-toggle" data-cmd="info-convolution-actions" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
			<div id="info-convolution-actions" class="config-help-info">
				<b>移除：</b> 删除选定的卷积文件。<br>
				<b>下载：</b> 下载选定的卷积文件。<br>
				<b>上传：</b> 上传卷积文件。如果文件已经存在，将被覆盖。
			</div>
		</div>
	</div>
</form>

<form class="form-horizontal $_cdsp_extensions_show" action="#extensions" method="post">
	<a id="extensions"></a>
	<legend>扩展</legend>
	<div class="control-group">
		$extensions_html
	</div>
</form>

<form class="form-horizontal" method="post">
	<div class="control-group">
		<label class="control-label">示例配置</label>
		<div class="controls">
			<a data-toggle="modal" href="#install-sample-configs"><button class="btn btn-medium btn-primary config-btn">更新</button></a>
			<span class="config-help-static">
				更新到最新的示例管道配置和系数文件。
				这些文件以版本号为前缀，例如 "V2"，以便于区分。
				<b>注意：</b> 同名文件将被覆盖，因此请务必在更新之前备份您的 CamillaDSP 文件。
			</span>
		</div>
	</div>
</form>

</div>
</div>

<form class="form-horizontal" method="post">
	<div id="remove-pipeline" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="remove-pipeline-label" aria-hidden="true">
		<input id="config_remove_id" type="hidden" name="cdsp_config" value="$_selected_config"/>
		<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h3>Remove Configuration?</h3>
		</div>
		<div class="modal-body txtmid">
			<h4>$_selected_config</h4>
			<span class="config-help-static">
				$_disable_rm_msg
			</span>
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
			<button class="btn btn-primary btn-submit" type="submit" name="remove" value="1" $_disable_rm>Yes</button>
		</div>
	</div>
</form>

<form class="form-horizontal" method="post">
	<div id="remove-coeff" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="remove-coeff-label" aria-hidden="true">
		<input id="coeff_remove_id" type="hidden" name="cdsp_coeffs" value="$_selected_coeff"/>
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h3>移除卷积？</h3>
		</div>
		<div class="modal-body txtmid">
			<h4>$_selected_coeff</h4>
			<span class="config-help-static">
				$_disable_rm_msg
			</span>
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
			<button class="btn btn-primary btn-submit" type="submit" name="remove" value="1" $_disable_rm>是的</button>
		</div>
	</div>
</form>

<form class="form-horizontal" method="post">
	<div id="copy-pipeline" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="copy-pipeline-label" aria-hidden="true">
		<input type="hidden" name="cdsp_config" value="$_selected_config"/>
		<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h3>复制管道？</h3>
		</div>
		<div class="modal-body">
			<div class="control-group">
				<div class="control-group">
					<label class="control-label" for="selected-pipeline-name">来源</label>
					<div class="controls">
						<input id="selected-pipeline-name" class="config-modal-input" type="text" value="$_selected_config" readonly>
					</div>
					<label class="control-label" for="copyto-pipeline-name">目标</label>
					<div class="controls">
						<input id="copyto-pipeline-name" class="config-modal-input" type="text" pattern="[A-Za-z0-9 \-_]*" name="copyto_pipeline_name" value="" autofocus>
					</div>
				</div>
			</div>
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
			<button class="btn btn-primary btn-submit" type="submit" name="copy_pipeline" value="1">是的</button>
		</div>
	</div>
</form>

<form class="form-horizontal" method="post">
	<div id="create-new-pipeline" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="new-pipeline-label" aria-hidden="true">
		<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h3>创建新管道？</h3>
		</div>
		<div class="modal-body">
			<div class="control-group">
				<label class="control-label" for="new-pipeline-name">名称</label>
				<div class="controls">
					<input class="config-modal-input" type="text" pattern="[A-Za-z0-9 \-_]*" id="new-pipeline-name" name="new_pipeline_name" value="" autofocus>
				</div>
			</div>
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
			<button class="btn btn-primary btn-submit" type="submit" name="create_new_pipeline" value="1">是的</button>
		</div>
	</div>
</form>


<form class="form-horizontal" method="post">
	<div id="install-sample-configs" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="install-sample-configs-label" aria-hidden="true">
		<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h3>更新到最新示例配置?</h3>
		</div>
		<div class="modal-body"></div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
			<button class="btn btn-primary btn-submit" type="submit" name="install_sample_configs" value="1">确认</button>
		</div>
	</div>
</form>

